package chenji.itemeditor.itemeditor;

import java.util.HashMap;
import java.util.HashSet;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

public class ItemEditorManager {
	public final static ItemEditorManager INSTANCE = new ItemEditorManager();
	private HashSet<Player> waitconfirm = Sets.newHashSet();
	private HashMap<Player, ItemEditor> editorcache = Maps.newHashMap();

	public void editItem(Player p, ItemStack i) {
		this.editorcache.put(p, new ItemEditor(i));
	}

	public void waitConfirm(Player p) {
		this.waitconfirm.add(p);
	}

	public boolean isWaitingConfirm(Player p) {
		return this.waitconfirm.contains(p);
	}

	public boolean contain(Player p) {
		return this.editorcache.containsKey(p);
	}

	public ItemEditor getEditor(Player p) {
		return this.editorcache.get(p);
	}

	public void clearEditor(Player p) {
		this.editorcache.remove(p);
	}

}
